/**
 * 
 */
;(function () {
	function commons(options) {
		$("#onlineEditor").hide();
		new oacore.Widget.Dialog({
		    callback: function (dialog) {
		    	var $dialog = $(dialog);
		    	//读取并生成联系人选择器
		    	var params = {};
		    	params[ACTIONS.DOC.ACCOUNT_BOOK_RB1.params.JOB_ID] = "<s:property value='jobId' />";
		    	$.util.Data.request({
						url: ACTIONS.DOC.ACCOUNT_BOOK_RB1.url,
						buffer: true,
						async: false,
						dataType: "json",
						data: params,
						success: function (data) {
							var dataAB;
							if(!ACTIONS.DOC.ACCOUNT_BOOK_RB1.data.ACCOUNT_BOOK)
								dataAB = data;
							else {
								dataAB = data[ACTIONS.DOC.ACCOUNT_BOOK_RB1.data.ACCOUNT_BOOK];
							}
				    		accountBook = new oacore.Widget.AccountBook({
				    			single: true,
								data: dataAB,
								dataForm: $("#commentForm"),
								autoHide: true,
								onHide: function () {
									if($.browser.msie)
										$("._hide").show();
								},
								onShow: function () {
									if($.browser.msie)
										$("._hide").hide();
								},
								host: $("input[type='text'].use-account-book:first"),
								pretreatment: function (data) {
									if(!data.id)
									{
										data.id = data.userInfoId;
										delete data.userInfoId;
									}
									if(!data.name)
									{
										data.name = data.userName;
										delete data.userName;
									}
									return data;
								}
							});
		    			}
			    	});
		    	$dialog.find("input.confirm").click(function () {
		    		 	SaveDocument();
						return true;
			    	});
		    	$dialog.find("button.cancel").click(function () {
		    			$dialog.dialog("close");
		    			return false;
			    	});
		    	var form = $dialog.find("form:first");
		    	form.validate({
						rules: {
							"detailData.opinion": {
								maxlength: 64
							}
						},
						messages: {
							"detailData.opinion": {
								maxlength: "备注项的长度不能超过64个字符"
							}
						}
			    	});
		    },
		    ui: "form/write_submit_to_comment_rb1",
		    data: {
					path: path,
					jobId: "<s:property value='detailData.jobDTO.jobId' />",
				    version: "<s:property value='detailData.documentVersion' />",
				    docPath: "<s:property value='detailData.documentPath' />",
				    documentId: "<s:property value='detailData.documentId' />",
				    action: agreeAndSubmitAction
			    },
		    options: {
		        modal: true,
		        header: false,
		        resizable: false,
		        width: 480,
		        height: 320,
		        close: function () {
		           accountBook.destroy();
		          	$("#onlineEditor").show();
		        }
		    }
		});
	};
})();